package com.gxpt.app.adapter;

import android.content.Context;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.gxpt.app.Constant;
import com.gxpt.app.R;
import com.gxpt.app.base.ListBaseAdapter;
import com.gxpt.app.base.SuperViewHolder;
import com.gxpt.app.bean.assesslist_bean;
import com.utils.ScreenUtils;
import com.utils.picasso.PicassoUtils;

/**
 * Created by Lzx on 2016/12/30.
 */

public class assesslist_Adapter extends ListBaseAdapter<assesslist_bean.assesslist> {

    Context context;
    int pic_view_width = 0;
    int pic_view_hight = 0;
    public assesslist_Adapter(Context context) {
        super(context);
        this.context = context;

        int Sviewwidth  = ScreenUtils.getScreenWidth(context);//
        pic_view_width  = Sviewwidth/8;
        pic_view_hight  = pic_view_width;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_life_service_list;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        assesslist_bean.assesslist item = mDataList.get(position);

        TextView txt_content = holder.getView(R.id.txt_content);
        txt_content.setText(item.content);

        TextView txt_create_time = holder.getView(R.id.txt_create_time);
        txt_create_time.setText(item.create_time);

        CheckBox ck_manner1 = holder.getView(R.id.ck_manner1);
        CheckBox ck_manner2 = holder.getView(R.id.ck_manner2);
        CheckBox ck_manner3 = holder.getView(R.id.ck_manner3);
        CheckBox ck_manner4 = holder.getView(R.id.ck_manner4);
        CheckBox ck_manner5 = holder.getView(R.id.ck_manner5);

        try {
            ImageView img_mem_headportrai = holder.getView(R.id.img_mem_headportrai);
            PicassoUtils.Picasso_Circle(context, Constant.IP+item.mem_headportrai,pic_view_width,img_mem_headportrai);

            switch (Integer.parseInt(item.manner)){
                case 1:
                    ck_manner1.setChecked(true);
                    ck_manner2.setChecked(false);
                    ck_manner3.setChecked(false);
                    ck_manner4.setChecked(false);
                    ck_manner5.setChecked(false);
                    break;
                case 2:
                    ck_manner1.setChecked(true);
                    ck_manner2.setChecked(true);
                    ck_manner3.setChecked(false);
                    ck_manner4.setChecked(false);
                    ck_manner5.setChecked(false);
                    break;
                case 3:
                    ck_manner1.setChecked(true);
                    ck_manner2.setChecked(true);
                    ck_manner3.setChecked(true);
                    ck_manner4.setChecked(false);
                    ck_manner5.setChecked(false);
                    break;
                case 4:
                    ck_manner1.setChecked(true);
                    ck_manner2.setChecked(true);
                    ck_manner3.setChecked(true);
                    ck_manner4.setChecked(true);
                    ck_manner5.setChecked(false);
                    break;
                case 5:
                    ck_manner1.setChecked(true);
                    ck_manner2.setChecked(true);
                    ck_manner3.setChecked(true);
                    ck_manner4.setChecked(true);
                    ck_manner5.setChecked(true);
                    break;
            }

        }catch (Exception e){
            e.printStackTrace();
        }


    }
}
